﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace AddIn.EA.Architecture.Presentation.Controls
{
    public partial class UcTypesCombo : UserControl
    {
        #region Properties
        public String SelectedItem
        {
            get
            {
                return cmbTypes.Text;
            }
            set
            {
                cmbTypes.SelectedItem = value;
            }
        }
        public Int32 SelectedIndex
        {
            get
            {
                return cmbTypes.SelectedIndex;
            }
            set
            {
                cmbTypes.SelectedIndex = cmbTypes.Items.Count > 0 ? value : -1;
            }
        }
        #endregion

        #region Start Control
        public UcTypesCombo()
        {
            InitializeComponent();
        }
        private void UcTypesCombo_Load(object sender, EventArgs e)
        {
            LoadTypes();
        }
        private void LoadTypes()
        {
            try
            {
                foreach (String itemType in Enum.GetNames(typeof(ComponentLogic.StandardProject.Types)))
                    cmbTypes.Items.Add(itemType);
                cmbTypes.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocorreu um erro ao carregar os tipos de objetos!\r\n\r\nDetalhes:" + ex.ToString(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        #endregion
    }
}

